package gspushmq.v1.app.subscribeapp.enumeration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 推送人群vip等级类型枚举类
 * @Author chengsj
 * @Date 2018/9/10 11:13
 * @Version 1.0
 * @company 上海朝阳永续信息技术有限公司
 * @copyright (c) 2015 SunTime Co'Ltd Inc. All rights reserved.
 *
*/
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @Description 用户权限枚举
 *
 * @Author chengsj
 * @Version 1.0
 *
 */
public enum TagEnum {

	G3_FREE(30001,"Go-Goal3.0金融终端-免费用户","G3_FREE"),
	G3_TRIAL(30002,"Go-Goal3.0金融终端-试用用户","G3_TRIAL"),
	G3_PAY(30003,"Go-Goal3.0金融终端-付费用户","G3_PAY"),

	G4_FREE(40001,"Go-Goal4.0金融终端-免费用户","G4_FREE"),
	G4_TRIAL(40002,"Go-Goal5.0金融终端-试用用户","G4_TRIAL"),
	G4_PAY(40003,"Go-Goal4.0金融终端-付费用户","G4_PAY"),

	GZ_FREE(50001,"Go-Goal智投金融终端-免费用户","GZ_FREE"),
	GZ_TRIAL(50002,"Go-Goal智投金融终端-试用用户","GZ_TRIAL"),
	GZ_ANALYZE(50003, "Go-Goal智投金融终端-分析版用户","GZ_ANALYZE"),
	GZ_PROFESSIONAL(50004, "Go-Goal智投金融终端-专业版用户","GZ_PROFESSIONAL"),
	GZ_CHIEF(50005,"Go-Goal智投金融终端-首席版用户","GZ_CHIEF"),
	GZ_CLASSIC(50006,"Go-Goal智投金融终端-经典版用户","GZ_CLASSIC"),
	GZ_DEHYDRATE(60001,"脱水研报订阅用户","DEHYDRATE");




	//消息类型
	private int code;
	//消息名称
	private String name;

	private String tag;

	TagEnum(int code, String name, String tag) {
		this.code = code;
		this.name = name;
		this.tag = tag;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	/**
	 *
	 * @Description
	 * @Author chengsj
	 * @Version 1.0
	 *
	 */
	public static TagEnum getEnumByCode(Integer code){
		if (code == null)
			return null;

		for (TagEnum p : TagEnum.values())
			if (p.getCode() == code)
				return p;

		return null;
	}

	public static String getTagByCode(Integer code){
		if (code == null)
			return null;

		for (TagEnum p : TagEnum.values())
			if (p.getCode() == code)
				return p.getTag();

		return null;
	}

	/**
	 *
	 * @Description 根据name获取相关key
	 * @Author chengsj
	 * @Version 1.0
	 *
	 */
	public static Integer getCodeByName(String name){
		if (StringUtils.isBlank(name))
			return null;

		for (TagEnum pe : TagEnum.values())
			if (pe.getName().equals(name))
				return pe.getCode();

		return null;
	}
	public static String getByNameCode(Integer code){
		if (code == null)
			return null;

		for (TagEnum pe : TagEnum.values())
			if (pe.getCode() == code)
				return pe.getName();

		return null;
	}
	/**
     * 
     * 方法描述 获取枚举值对应的key-value集合
     *
     * @return
     * 
     * @author yaomy
     * @date 2018年5月16日 下午7:04:26
     */
    public static List<Map<String, Object>> toMap(){
    	List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    	for(TagEnum type : TagEnum.values()) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("code", type.code);
    		map.put("name", type.name);
    		list.add(map);
    	}
    	return list;
    }

	public static boolean contain(Integer code){
		if (code == null)
			return false;
		for (TagEnum en : TagEnum.values())
			if (en.getCode() == code)
				return true;
		return false;
	}
}
